package com.iamdigger.queldorei.monitor.exe;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 监控任务执行线程池
 * Created by Sam on 2016/4/8.
 */
public class MonitorTaskExecutor {

    static class ThreadPoolHolder {
        static final int CORE_POOL_SIZE = 10;
        static final int MAX_POOL_SIZE = 20;
        static final int IDLE_WAIT_TIME = 5000;
        static final BlockingQueue<Runnable> QUEUE = new LinkedBlockingQueue<Runnable>();
        static final ThreadPoolExecutor tpe = new ThreadPoolExecutor(
                CORE_POOL_SIZE, MAX_POOL_SIZE, IDLE_WAIT_TIME, TimeUnit.MILLISECONDS, QUEUE);
    }

    public void acceptTask(MonitorTask mt) {
        ThreadPoolHolder.tpe.execute(mt);
    }
}
